import torch


def one_hot(label, depth=10):
    '''
    '''
    out = torch.zeros(label.size(0), depth)
    idx = torch.LongTensor(label).view(-1, 1)
    out.scatter_(dim=1, index=idx, value=1)
    return out

# def show_from_tensor(tensor, title=None):
#     img = tensor.clone()
#     img = tensor_to_np(img)
#     plt.figure()
#     plt.imshow(img)
#     if title is not None:
#         plt.title(title)
#     plt.pause(0.001)